package com.sunny.example;

import java.util.Scanner;

/**
 * HJ35 蛇形矩阵
 */
public class HJ35 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
//            String input = scanner.nextLine();
            int input = scanner.nextInt();
            StringBuffer stringBuffer = new StringBuffer();
            int yDelta = 1;//列等差数列，每列加1
            int y0 = 1;//第一个数固定为1
            for (int i = 1; i <= input; i++) {//行
//                line[i] = line[i-1] + input - 1;
                int x0 = y0;//第一行一个固定为0
                int xDelta = i + 1;
                for (int j = 1; j <= input - i + 1; j++) {//列
                    System.out.print(x0 + " ");//打印
                    //等差数列
                    x0 += xDelta++;
                }
                //换行
                System.out.println("");
                y0 += yDelta++;
            }

        }
    }
}
